package com.gph.saviorframework.echarts.test.bar;

import com.gph.saviorframework.echarts.axis.CategoryAxis;
import com.gph.saviorframework.echarts.axis.ValueAxis;
import com.gph.saviorframework.echarts.code.*;
import com.gph.saviorframework.echarts.series.Bar;
import com.gph.saviorframework.echarts.test.util.EnhancedOption;
import org.junit.Test;

/**
 * 组成瀑布图
 */
public class BarTest5 {

    @Test
    public void test() {
        //地址：http://echarts.baidu.com/doc/example/bar4.html
        EnhancedOption option = new EnhancedOption();
        option.title("深圳月最低生活费组成（单位:元）");
        option.tooltip().trigger(Trigger.axis).axisPointer().type(PointerType.shadow);
        option.tooltip().formatter("function (params) {" +
                "            var tar = params[0];" +
                "            return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;" +
                "        }");
        option.toolbox().show(true).feature(Tool.mark, Tool.dataView, Tool.restore, Tool.saveAsImage);
        option.calculable(true);
        option.xAxis(new CategoryAxis().data("总费用", "房租", "水电费", "交通费", "伙食费", "日用品数"));
        option.yAxis(new ValueAxis());

        Bar bar = new Bar("辅助");
        bar.stack("总量");
        bar.itemStyle().normal().barBorderColor("rgba(0,0,0,0)").color("rgba(0,0,0,0)");
        bar.itemStyle().emphasis().barBorderColor("rgba(0,0,0,0)").color("rgba(0,0,0,0)");
        bar.data(0, 1700, 1400, 1200, 300, 0);

        Bar bar2 = new Bar("生活费");
        bar2.stack("总量");
        bar2.itemStyle().normal().label().position(Position.inside).show(true);
        bar2.data(2900, 1200, 300, 200, 900, 300);

        option.series(bar, bar2);
        option.exportToHtml("bar5.html");
        option.view();
    }
}
